package com.coffee.takeoutserver.service.impl;

import com.coffee.takeoutserver.bean.GoodsTypeInfo;
import com.coffee.takeoutserver.bean.GoodsTypeInfoExample;
import com.coffee.takeoutserver.dao.GoodsTypeInfoMapper;
import com.coffee.takeoutserver.service.GoodsTypeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
class GoodsTypeInfoServiceImpl implements GoodsTypeInfoService {
    @Autowired
    private GoodsTypeInfoMapper goodsTypeInfoMapper;

    @Override
    public List<GoodsTypeInfo> getGoodsTypeInfoListBySellerId(int sellerId) {
        GoodsTypeInfoExample goodsTypeInfoExample = new GoodsTypeInfoExample();
        goodsTypeInfoExample.setOrderByClause("id desc");
        GoodsTypeInfoExample.Criteria criteria = goodsTypeInfoExample.createCriteria();
        criteria.andSelleridEqualTo(sellerId);
        return goodsTypeInfoMapper.selectByExample(goodsTypeInfoExample);
    }


    @Override
    public void deleteGoodsTypeInfoById(int id) {
        goodsTypeInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insertGoodsTypeInfo(GoodsTypeInfo goodsTypeInfo) {
        goodsTypeInfoMapper.insert(goodsTypeInfo);
    }

    @Override
    public void updateGoodsTypeInfoById(GoodsTypeInfo goodsTypeInfo) {
        goodsTypeInfoMapper.updateByPrimaryKeySelective(goodsTypeInfo);
    }
}
